<? 
	$title="View Discount Voucher"; 
	$pageid="1";
	$accessid="a00";
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php");
	
	checkAccess("allow_online_member_view",1); 
	
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?

		
	if(!empty($_GET['action']))
	{
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data Added!</div>";
				break;
			case 2:
				$msg="<div class='dw_failed'>Voucher code already exist,update failed!</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;	
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}else{
		$msg="";
	}
	$id=$_GET['id'];
	$get_dv=mysql_query("select * from os_discount_voucher_used where member_id=$id")or die(mysql_error());
	$get_mem=mysql_query("select * from os_member where id=$id");
	
?>
<table width="100%">

<td align="left" valign="top">
	<div class="title">Discount Voucher List For <?= mysql_result($get_mem,0,"name") ?></div>
	    <div id="divMsg"><?= $msg ?></div>
    <table width="100%" cellpadding="2" cellspacing="1">
		<? if(mysql_num_rows($get_dv)==0){ ?>
		<tr>
		 <td height="200" valign="middle" colspan="8" align="center">
			<font color="#FF0000">- No record found -</font><br />	
		 </td>
		</tr>
		<? }else{ ?>
		
		<tr class="table_header" >
			<Td width="9%">No</Td>
			<td width="22%">Voucher Name</td>
			<td width="25%">Voucher Code</td>
			<td width="30%">Status</td>
		
		</tr>
		<?
			$no=1;
			while($a=mysql_fetch_array($get_dv))
			{
				if($no%2==0)
				{
					$class1="table_item_even";
					$class2="table_item_odd";
				}
				else
				{
					$class1="table_item_odd";
					$class2="table_item_even";
				}
				
				
				$get_dv_info=mysql_query("select * from os_discount_voucher where id=".$a['voucher_id']);
				$v=mysql_fetch_array($get_dv_info,MYSQL_ASSOC);
				if($a['status']==1)
				{
					$bill_id=$a['bill_id'];
					
					$status="Used [<a href='order_viewfull.php?id=$bill_id'>View Order</a>]";
					
				}else{
					$status="Unuse";
					
				}
		?>	
		  <tr height="20" valign="top" class="<?= $class1 ?>"  onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='<?= $class1 ?>'">
			<td><?= $no ?></td><Td> <?= $v['voucher_name'] ?></Td>
            <Td><?= $v['voucher_code'] ?></Td>
            <td><?= $status ?>
            
            </td>
           
		</Tr>
		<? $no++;}} ?>
	</table>
    <input type="button" value="Back" onclick="history.go(-1)" />
	</td>
</table>

<? require("required/footer.php"); ?>

